package com.big.gateway.controller;

import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * <p>
 * 查询 Gateway 路由信息接口
 * </p>
 *
 * @author 山归岿
 * @create 2025-06-13-23:32
 */
@RestController
@RequestMapping("gateway")
public class GatewayRouteController {
    private final RouteDefinitionLocator routeDefinitionLocator;

    public GatewayRouteController(RouteDefinitionLocator routeDefinitionLocator) {
        this.routeDefinitionLocator = routeDefinitionLocator;
    }

    /**
     * 获取所有路由定义
     *
     * @return 路由列表
     */
    @GetMapping("/routes")
    public Flux<RouteDefinition> getRoutes() {
        return routeDefinitionLocator.getRouteDefinitions();
    }
}
